import React, { Component } from 'react';
import './username.scss'
class username extends Component {
  state = {
    username: '',
    pass: ''
  }
  getUsername = () => {
    const { username, pass } =JSON.parse(localStorage.getItem('username')) 
    this.setState({
      username,
      pass
    })
  }
  // 声明周期只触发一次
  componentDidMount () {
    this.getUsername()
  }
  render () {
    return (
      <div className='userName'>
        {/* 用户信息 */}
        <p>账号：{this.state.username}</p>
        <p>密码：{this.state.pass}</p>
      </div>
    );
  }
}

export default username;